﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PServiceBus.Core.Interface;
using PServiceBus.Core.Runtime.Extensions;
using PServiceBus.Services.Web.Runtime;

namespace PServiceBus.Services.Web.DTO {
    public class TransportInfo {
        public string Name { get; set; }
        public int TypeID { get; set; }
        public Dictionary<string, object> Parameters { get; set; }
        public ITransport ToTransport() {
            if (Parameters == null) throw new InvalidOperationException("Parameters");
            if (TypeID < 0) throw new InvalidOperationException("TypeID");
            return Parameters.ToJson().FromJson<ITransport>(TransportHelper.GetTransportType(TypeID));
        }
    }
}
